import { isDaytime } from '@/utils/index.js'

class Theme {
  set = (mode) => {
    localStorage.setItem('theme_mode', mode)
    let _html = document.getElementsByTagName('html')[0]
    // let link = document.getElementById('theme-style');
    _html.classList.remove('auto', 'light', 'dark')

    if (mode === 'auto') {
      mode = isDaytime() ? 'light' : 'dark'
    }
    // link.setAttribute('href', `/github-markdown-${mode}.css`);
    _html.classList.add(mode)
  }

  get = () => {
    return localStorage.getItem('theme_mode')
  }
}

export { Theme }

export default Theme
